package collections2;

import java.io.*;

public class Test2 {
  public static void main(String[] args) {
      /**
       * 可直接写在File中
       */
      String url = "D:/陪伴是最长情的告白.txt";
      /**
       * 读取文件数据
       */
      File file = new File(url);
      if (!file.exists() || file.isDirectory())
      {
          System.out.println("文件不存在！");
          return;
      }
      StringBuffer sb = null;
      BufferedReader br;
      try
      {
          br = new BufferedReader(new FileReader(file));
          String temp = null;
          sb = new StringBuffer();
          temp = br.readLine();
          while (temp != null)
          {
              sb.append(temp + "\r");
              temp = br.readLine();
          }
      }
      catch (Exception e)
      {
          e.printStackTrace();
      }
      /** 读取的文件内容 */
      String info = sb.toString();
      int num = 0;
      for (int i = 0; i < info.length(); i++)
      {
    
          if ("陪".equals(info.charAt(i) + ""))
          {
              num++;
          }
      }
      System.out.println("字符出现了：" + num+"次");
      System.out.println(info.toString());
  }
  {
}
}
